package com.edu.koTA07.xmlreader;



import java.io.InputStream;

import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;

import org.xml.sax.InputSource;
import org.xml.sax.XMLReader;

import android.app.ListActivity;

import com.edu.koTA07.XmlDataSet.PesananXmlDataSet;
import com.edu.koTA07.xmlHandler.PesananXMLHandler;

public class PesananXMLtoDataSet extends ListActivity{	
    PesananXmlDataSet pesanan = null;
    

	public PesananXMLtoDataSet(InputStream in) {
		
		
		try {
			/** Handling XML */
			SAXParserFactory spf = SAXParserFactory.newInstance();
			SAXParser sp = spf.newSAXParser();
			XMLReader xr = sp.getXMLReader();
			/** Send URL to parse XML Tags */
			//URL sourceUrl = new URL(
			//		"http://www.androidpeople.com/wp-content/uploads/2010/06/example.xml");
			//InputStream in = this.getResources().openRawResource(R.raw.customer);
			/** Create handler to handle XML Tags ( extends DefaultHandler ) */
			PesananXMLHandler pesananXMLHandler = new PesananXMLHandler();
			xr.setContentHandler(pesananXMLHandler);
			//xr.parse(new InputSource(sourceUrl.openStream()));
			xr.parse(new InputSource(in));
		} catch (Exception e) {
			System.out.println("XML Pasing Excpetion = " + e);
		}
		pesanan = PesananXMLHandler.pesanan;
	}
	public PesananXmlDataSet getPesananList()
	{
		return pesanan;
	}


}   

